import http from './http'

/**
 * 产品详情
 * */
export async function detail (pid) {
  const res =  await http.get(`/product/detail?pid=${pid}`)
  if (res.status === 200) {
    return res.data
  }
}

/**
 * 产品列表
 * */
export async function products (type, search) {
  let query = `/product/products?type=${type}`
  if (search) {
    query += `&search=${search}`
  }
  const res = await http.get(query)
  if (res.status === 200) {
    return res.data
  }
}

/**
 * 图表接口 - btc
 * */
export async function btcRate () {
  const res =  await http.get('/product/btcRate')
  if (res.status === 200) {
    return res.data
  }
}

/**
 * 图表接口 - ai
 * */
export async function aiRate () {
  const res =  await http.get('/product/aiRate')
  if (res.status === 200) {
    return res.data
  }
}
